package com.qf.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qf.constant.MessageConstant;
import com.qf.entity.Result;
import com.qf.pojo.Setmeal;
import com.qf.service.SetMealService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhouhao
 * @create 2021-12-23 21:31
 */
@RestController
@RequestMapping("setmeal")
public class SetMealController {

    @Reference
    private SetMealService setMealService;

    //查询所有套餐
    @RequestMapping("getAllSetmeal")
    public Result getAllSetmeal(){
        try {
            List<Setmeal> list =  setMealService.getAllSetMeal();
            return new Result(true, MessageConstant.GET_SETMEAL_LIST_SUCCESS,list);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.GET_SETMEAL_LIST_FAIL);
        }
    }

    //根据id查询套餐的详细信息
    @RequestMapping("findById")
    public Result findById(Integer id){
        try {
            Setmeal setmeal =  setMealService.findById(id);
            return new Result(true,"查询成功",setmeal);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,"查询失败");
        }
    }
}
